<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@	page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="hql" value="from Member where 1 = 1  " />
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 20, 10)}" />
<c-rt:if test="${!empty param.loginIdParam or !empty param.emailParam}">
	<c-rt:if test="${not empty param.loginIdParam}">
		<c-rt:set var="hql">${hql} and loginId like ? </c-rt:set>
		<c-rt:set var="lip">%${param.loginIdParam}%</c-rt:set>
		<c-rt:set var="params" value="${pu:addToList('paras', lip)}" />
	</c-rt:if>
	<c-rt:if test="${not empty param.emailParam}">
		<c-rt:set var="ep">%${param.emailParam}%</c-rt:set>
		<c-rt:set var="hql">${hql} and email like ? </c-rt:set>
		<c-rt:set var="params" value="${pu:addToList('paras', ep)}" />
	</c-rt:if>
</c-rt:if>
<c-rt:set var="hql">${hql} and rank = ? </c-rt:set>
<c-rt:set var="params" value="${pu:addToList('paras', rankParam)}" />
<c-rt:set var="hql">${hql} and status = ? </c-rt:set>
<c-rt:set var="params" value="${pu:addToList('paras', statusParam)}" />
<c-rt:if test="${not empty param.applySourceParam}">
	<c-rt:set var="hql">${hql} and applySource like '%'||?||'%' </c-rt:set>
	<c-rt:set var="params" value="${pu:addToList('paras', applySourceParam)}" />
</c-rt:if>
<c-rt:if test="${not empty param.memberIdParam}">
	<c-rt:set var="hql">${hql} and memberId = ? </c-rt:set>
	<c-rt:set var="params" value="${pu:addToList('paras', memberIdParam)}" />
</c-rt:if>
<c-rt:set var="members" value="${pu:queryByHql(hql, params, tp)}" />

<s:actionerror />
<s:actionmessage />
<s:fielderror />
<br />
<h1>会员管理
<!-- <div class="f-link"><a href="${midContextPath }/member/add.do">新增</a></div>-->
</h1>
<div class="data-form"><s:form action="search.do" method="post">
	<b>登入代码：</b>
	<input name="loginIdParam" id="loginIdParam" type="text" title="登入代码"
		value="${loginIdParam}">
	<b>电子邮件：</b>
	<input name="emailParam" id="emailParam" type="text"
		value="${emailParam}"><br/>
	<b>会员等级:</b>
	<s:select label="会员等级" name="rankParam" list="memberRank.options" headerKey="" headerValue="全部" 
		listKey="key" listValue="value.name" />
	<b>会员状态：</b>
	<s:select label="会员状态" name="statusParam" list="memberStatus.options" headerKey="" headerValue="全部"
		listKey="key" listValue="value.name" /><br/>
	<b>申请来源</b>
	<s:textfield name="applySourceParam"/>
	<b>会员编号</b>
	<s:textfield name="memberIdParam"/>
	<input type="button" value="搜寻" onclick="this.form.submit();" />
</s:form></div>
<br />
<br /><font color="red"><b>红字表示尚未激活</b></font>
<table class="tb-1" width="100%">
	<thead>
		<tr>
			<th>#</th>
			<th>登入代码</th>
			<th>行动电话</th>
			<th>电子邮件</th>
			<th>性别</th>
			<th>生日</th>
			<th>分级</th>
			<th>狀態</th>
			<th>注册时间</th>
			<th>站点</th>
		</tr>
	</thead>
	<tbody>
		<c-rt:forEach items="${members}" var="member" varStatus="rows_index">
			<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
				<td><a href="${midContextPath }/member/view.do?memberId=${member.memberId}" />${member.memberId}</a></td>
				<td>
				<c-rt:choose>
					<c-rt:when test="${empty(member.activeDate)}">
						<font color="red"><b>${member.loginId}</b></font>
					</c-rt:when>
					<c-rt:otherwise>
						${member.loginId}
					</c-rt:otherwise>
				</c-rt:choose>
				</td>
				<td>${pu:maskMobile(member.mobile)}</td>
				<td>${pu:maskEmail(member.email)}</td>
				<td>
					<c-rt:if test="${member.sex eq 'M'}">男</c-rt:if>
					<c-rt:if test="${member.sex eq 'F'}">女</c-rt:if>
				</td>
				<td>
					<fmt-rt:formatDate value="${member.birthday}" pattern="yyyy-MM-dd"/>
				</td>
				<td>${memberRank.options[member.rank].name}</td>
				<td>${memberStatus.options[member.status].name}</td>
				<td><fmt-rt:formatDate value="${member.createDate}"
					pattern="yyyy-MM-dd HH:mm" /></td>
				<td>${domainSrc.options[member.domainSrc].name}</td>
			</tr>
		</c-rt:forEach>
	</tbody>
</table>
<pageable:Pageable url="${midContextPath}/member/search.do" formname="memberForm"
	key="tpp" />